<%!String title = "Context info";%>
<%@ include file="header.jsp"%>
<h1>Context Info!</h1>

<%
	if (s.getAttribute("currentUser") == null) {
		response.sendRedirect(response.encodeRedirectURL("home.jsp"));
	}
	else if (!(s.getAttribute("currentUser") instanceof Admin)) {
		response.sendRedirect(response.encodeRedirectURL("home.jsp"));
	}
%>

<%
	ArrayList<Pizza> contextPizzas = (ArrayList<Pizza>) c.getAttribute("pizzas");
%>
<%
	ArrayList<User> contextUsers = (ArrayList<User>) c.getAttribute("users");
%>
<br>
<br>
<h3>Current user:</h3>
<% if(cu!=null) out.print(cu.toString()); else out.print("There is no current user");%>
<br>
<br>
<h3>Pizzas:</h3>
<table>
	<%
		if (contextPizzas != null) {
			for (int i = 0; i < contextPizzas.size(); i++) {
				Pizza p = contextPizzas.get(i);
				int count = i;
				out.print("<tr><td>"
						+ p.toString()
						+ "</td> <td> <form method=post action=controller><input type=submit name=adminpage_remove value=\"remove\"><input type=hidden name=adminpage_pizzaid value="
						+ count + "></form></td></tr> ");
			}
		}
	%>
</table>
<br>
<br>
<h3>Users:</h3>
<table>
	<%
		if (contextUsers != null) {
			for (int i = 0; i < contextUsers.size(); i++) {
				User u = contextUsers.get(i);
				out.print("<tr><td>" + u.toString() + "</td></tr>");
			}
		}
	%>
</table>
<br>
<h3>Add a new pizza:</h3>
<form method=post action=controller>
	Name: <br>
	<input name=pizza_name type=text size=60><br> Price:<br>
	<input name=pizza_price type=text size=60><br> Toppings: <br>
	<input name=pizza_toppings type=text size=60> <br> <input
		type=submit name=adminpage_add value="add pizza"> <br> <br>
	<form method="post">
		<input type="button" value="Menu" OnClick="location.href='index.html'">
	</form>
	</body>
	</html>